//
//  Helper.h
//  leetcode
//
//  Created by Ellie on 2021/1/28.
//  Copyright © 2021 Ellie. All rights reserved.
//

#ifndef Helper_h
#define Helper_h

#include <string>
#include <list>

using namespace std;

ListNode* getMedian(ListNode* left, ListNode* right);
void Print_Nodes(string notes, deque<TreeNode*>& input);

ListNode* buildList(vector<int>& input);
void buildVector(ListNode* input, vector<int>& result);

void printList(string notes, ListNode* head);
void myshuffle(vector<int>& input);

void printstdlist(string notes, std::list<int>& input);

// template method should be in header file
// https://stackoverflow.com/questions/495021/why-can-templates-only-be-implemented-in-the-header-file
template <class T>
void Printf_deque(string notes, deque<T> &input)
{
    typename deque<T>::iterator begin = input.begin();
    typename deque<T>::iterator end = input.end();
    
    cout << notes << ":" << endl;
    for(;begin != end;begin++)
    {
        cout << *begin << " ";
    }
    cout << endl;
}

template <class T>
void printfVector(string notes, vector<T> &result)
{
    int size = result.size();
    cout << notes << ":";
    for(int i=0;i<size;i++)
    {
        cout << result[i] << " ";
    }
    cout << endl;
}

struct compareNode
{
    bool operator()(const ListNode* l, const ListNode* r)
    {
        // 小顶堆
        return l->val > r->val;
        // 大顶堆
        // return l->val < r->val;
    }
};

#endif /* Helper_h */
